<?php
/**
 * 广告模板配置函数
 */
function get_types() {
	$poster_template = getcache('poster_template_'.$siteid, 'commons');
	$TYPES = array();
	if (is_array($poster_template) && !empty($poster_template)){
		foreach ($poster_template as $k => $template) {
			$TYPES[$k] = $template['name'];
		}
	} else {
		$TYPES = array('banner'=>L('banner'), 'fixure'=>L('fixure'), 'float'=>L('float'), 'couplet'=>L('couplet'), 'imagechange'=>L('imagechange'),  'imagelist'=>L('imagelist'), 'text'=>L('text'), 'code'=>L('code'),);
	}
	return $TYPES;
}

/**
 * 判断表是否存在
 * @param $tablename 表名
 */
	function table_exists($tablename){
		$tables = M()->query('SHOW TABLES;');
		foreach ($tables as $key=>$value){
			$tables[$key] = $value['Tables_in_'.C('DB_NAME')];
		}
		return in_array($tablename, $tables) ? 1 : 0;
	}